package my.game.Descension;

import java.awt.Image;

import javax.swing.ImageIcon;

public class Sprite {
	
	private int x,y;
	private Image sprite_img;
	private Image backgroundImage;
	private boolean background = false;
	private boolean passable = false;
	private boolean isDoor = false;
	private String info;
	private String teleportTo;
	
	public Sprite(String sprite) {
		x = 0;
		y = 0;
		info = null;
		if (sprite != "null") {
		ImageIcon ii = new ImageIcon("sprites/"+sprite+".png");
		sprite_img = ii.getImage();
		}
		else sprite_img = null;
		
		checkProperties(sprite);
		

	}
	
	public void checkProperties(String sprite) {
		
		// Gives trees grass under them.
		if (sprite !="grass" && sprite != "null") {
			backgroundImage = new ImageIcon("sprites/grass.png").getImage();
			passable = false;
		}
				
		else {
			backgroundImage = null;
			passable = true;
		}
		
		if (sprite == "door") {
			
		}
		
		if (sprite == "cave_door") {
			
		}
		
		
	}
	
	
	public Image getImage() {
		return sprite_img;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public void setInfo(String in) {
		info = in;
	}
	public String getInfo() {
		return info;
	}
	
	// For map foreground/ background elements.
	public void setIsBackground(boolean back) {
		background = back;
	}
	
	public boolean isBackground() {
		return background;
	}
	
	public Image getBackgroundImage() {
		return backgroundImage;
	}
	
	public void setPassable(boolean pass) {
		passable = pass;
	}
	
	public boolean isPassable() {
		return passable;
	}
	
	public boolean isDoor() {
		return isDoor;
	}
	
	// For loading a new map
	public String newLocation() {
		return teleportTo;
	}
	
	public void setDoor(boolean door, String newLocation) {
		isDoor = door;
		teleportTo = newLocation;
	}
	
	public void setDoor(boolean door) {
		isDoor = door;
	}
}
